The present invention relates generally to evaluating expressions, and more particularly to method and apparatus that evaluate an expression based upon results obtained from a database.
Computer systems commonly need to perform actions in response to a defined condition being satisfied. Accordingly, computer systems need to determine whether the defined condition has been satisfied so that the computer system may take the appropriate actions. Prior art systems have typically determined whether a defined condition has been satisfied by directly evaluating a Boolean expression that defines the condition.
A Boolean expression includes operands and operators. In particular, the operators define a relationship between the operands. If the operands satisfy the defined relationship then the Boolean expression evaluates to a truth value of true; otherwise, the Boolean expression evaluates to a truth value of false. For example, (Day=xe2x80x9cMondayxe2x80x9d) AND (Year=xe2x80x9c1998xe2x80x9d) is a Boolean expression where Day, xe2x80x9cMondayxe2x80x9d, Year, and xe2x80x9c1998xe2x80x9d are operands and (,), AND, and=are operators. Moreover, the operands of the Boolean expression are typically either (i) literals such as xe2x80x9cMondayxe2x80x9d and xe2x80x9c1998xe2x80x9d that do not change in value during the operation, or (ii) variables such as Day and Year that represent values which may change during operation.
Evaluation of an arbitrary Boolean expression is a somewhat complex process. In particular, a process which evaluates the arbitrary Boolean expression must (i) determine whether the syntax of the Boolean expression is valid, and (ii) determine how to correctly evaluate the Boolean expression if the syntax of the Boolean expression is valid. To this end, the process typically parses the Boolean expression to generate a data structure such as a binary tree structure which represents the Boolean expression. Then, the process traverses the generated data structure in order to resolve the Boolean expression to a truth value.
Existing databases already (i) determine whether the syntax of a database query is valid, (ii) determine whether records of the database satisfy the criteria of the database query, and (iii) generate a database result table that includes each record of the database which satisfies the criteria of the database query. Since much of the processing of a database query by a database is akin to the processing required to resolve a Boolean expression to a truth value, what is needed is a method and apparatus that evaluate an arbitrary Boolean expression by offloading a portion of the processing burden to a database, and resolving the Boolean expression based upon results obtained from the database.
In accordance with one embodiment of the present invention, there is provided a method of evaluating an expression. One step of the method includes generating a database query that is representative of the expression. Another step of the method includes processing the database query to obtain database result information from a database. The method also includes the step of resolving the expression to an expression value by analyzing the database result information.
Pursuant to another embodiment of the present invention, there is provided a method of evaluating a Boolean expression that includes a first subexpression. One step of the method includes generating a database query that is representative of the Boolean expression. Another step of the method includes processing the database query to obtain a database result table that includes a first result row if a first database row of a database table satisfies the first sub-expression. Moreover, the method includes the step of resolving the Boolean expression to a truth value by analyzing the database result table.
Pursuant to yet another embodiment of the present invention, there is provided a computer readable medium that configures a processor to evaluate a Boolean expression that includes a first sub-expression. The computer readable medium includes a plurality of instructions. The plurality of instructions when executed by the processor causes the processor to generate a database query that is representative of the Boolean expression. The plurality of instructions when executed by the processor also causes the processor to process the database query to obtain a database result table that includes a first result row if a first database row of a database table satisfies the first sub-expression. The plurality of instructions when executed by the processor further causes the processor to resolve the Boolean expression to a truth value by analyzing the database result table.
It is an object of the present invention to provide a new and useful method and apparatus for evaluating expressions.
It is another object of the present invention to provide an improved method and apparatus for evaluating expressions.
It is an additional object of the present invention to provide a method and apparatus that evaluate an arbitrary Boolean expression in a manner that does not require direct evaluation of the Boolean expression.
It is yet another object of the present invention to provide a method and apparatus that offloads a portion of the processing of a Boolean expression to a database.